package impl

import (
	"ylb/entity"
	"ylb/mapper"
)

type UserRelevanceServiceImpl struct {
	mapper mapper.UserReleVanceMapper
}

func NewUserRelevanceServiceImpl() *UserRelevanceServiceImpl {
	var user UserRelevanceServiceImpl
	user.mapper = mapper.NewUserReleVanceMapper()
	return &user
}

func (u UserRelevanceServiceImpl) Bind(relevance entity.UserRelevance) (int, error) {
	if relevance.UserId == 0 {
		panic("Bind() userID is Null")
	}
	userRelevance := u.mapper.InsertUserRelevance(relevance)
	return userRelevance, nil
}

func (u UserRelevanceServiceImpl) BindEmail(userId uint, email string) (int, error) {
	//TODO implement me

	return u.Bind(entity.UserRelevance{UserId: userId, Email: email})

}

func (u UserRelevanceServiceImpl) BindWx(userId uint, wx string) (int, error) {
	//TODO implement me
	return u.Bind(entity.UserRelevance{UserId: userId, Wx: wx})
}

func (u UserRelevanceServiceImpl) BindQQ(userId uint, qq string) (int, error) {
	//TODO implement me
	return u.Bind(entity.UserRelevance{UserId: userId, QQ: qq})
}

func (u UserRelevanceServiceImpl) BindPhone(userId uint, phoneNumber string) (int, error) {
	//TODO implement me
	return u.Bind(entity.UserRelevance{UserId: userId, Phone: phoneNumber})
}
